package com.itheima.Test22;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class UploadServer {
    public static void main(String[] args) throws IOException {
        ServerSocket socket = new ServerSocket(10000);
        while (true) {
            Socket accept = socket.accept();
            InputStream is = accept.getInputStream();

            FileOutputStream fos = new FileOutputStream("Test02\\copy.jpg");
            int i;
            byte[] bytes = new byte[1024];
            while ((i = is.read(bytes)) != -1) {
                fos.write(bytes, 0, i);
            }
            OutputStream os = accept.getOutputStream();
            os.write("上传成功".getBytes());
            fos.close();
            accept.close();
        }
    }
}
